package com.xzz.insitu;

/**
 * @author: hhz
 * @create: 2021-12-29 13:50
 **/
public class MoveZeroes {
    public static void main(String[] args) {
        int[] nums = new int[]{0, 1, 32, 0, 2, 3, 0, 12, 34};
//        int[] nums = new int[]{0,1,0,3,12};
        moveZeroes(nums);
        System.out.println();

    }
    public static void moveZeroes(int[] nums) {
        int left= 0;
        int right = 0;
        while (right<nums.length){
            if(nums[right] != 0){
                nums[left] = nums[right];
                left++;
            }
            right++;
        }
        for(int i = left;i<nums.length;i++){
            nums[i]= 0;
        }
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}
